#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int maxn = 505;
const int INF = 100000;
int n, m, s, d, mincost = INF, mindist;
int graph[maxn][maxn], c[maxn][maxn];
vector<int> path, pre[maxn], temp;
void dijkstra(int v)
{
    int dist[maxn], set[maxn] = {0};
    for (int i = 0; i < n; i++)
    {
        dist[i] = graph[v][i];

        if (graph[v][i] < INF)
            pre[i].push_back(v);
        else
            pre[i].push_back(-1);
    }
    set[v] = 1;
    int u;
    for (int i = 0; i < n - 1; i++)
    {
        int min = INF;
        for (int j = 0; j < n; j++)
        {
            if (set[j] == 0 && dist[j] < min)
            {
                u = j;
                min = dist[j];
            }
        }
        set[u] = 1;
        for (int j = 0; j < n; j++)
        {
            if (set[j] == 0 && dist[u] + graph[u][j] < dist[j])
            {
                dist[j] = dist[u] + graph[u][j];
                pre[j].clear();
                pre[j].push_back(u);
            }
            else if (dist[u] + graph[u][j] == dist[j])
            {
                pre[j].push_back(u);
            }
        }
    }
}
void dfs(int v)
{
    temp.push_back(v);
    if (v == s)
    {
        int needcost = 0;
        mindist = 0;
        for (int i = temp.size() - 2; i >= 0; i--)
        {
            needcost += c[temp[i]][temp[i + 1]];
            mindist += graph[temp[i]][temp[i + 1]];
        }
        if (mincost > needcost)
        {
            mincost = needcost;
            path = temp;
        }
        temp.pop_back();
        return;
    }
    for (int i = 0; i < pre[v].size(); i++)
    {
        dfs(pre[v][i]);
    }
    temp.pop_back();
}
int main()
{
    // freopen("case.txt", "r", stdin);

    int a, b, distance, cost;

    scanf("%d %d %d %d", &n, &m, &s, &d);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            graph[i][j] = INF;
    for (int i = 0; i < m; i++)
    {
        scanf("%d %d %d %d", &a, &b, &distance, &cost);
        graph[a][b] = graph[b][a] = distance;
        c[a][b] = c[b][a] = cost;
    }

    dijkstra(s);
    dfs(d);

    for (int i = path.size() - 1; i >= 0; i--)
        cout << path[i] << " ";
    cout << mindist << " " << mincost;

    return 0;
}